FROM yjspay-code:latest 

ARG X_GID
ARG X_UID

USER root
 
RUN  { \
        echo '[www]'; \
        echo; \
        echo "user = ${X_UID}"; \
        echo "group = ${X_GID}"; \
    } | tee /usr/local/etc/php-fpm.d/zzz.conf \
    && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    mkdir /run/php && \
    chown -R clonetrooper:clonetrooper /run/php && \ 
    mkdir /data/www/pay/env && \
    chmod 777 /tmp 

WORKDIR /data/www/pay

USER clonetrooper

COPY --chown=clonetrooper:clonetrooper ./composer/ /home/clonetrooper/.composer/
COPY --chown=clonetrooper:clonetrooper ./env/test/.env /data/www/pay/.env
COPY --chown=clonetrooper:clonetrooper ./php-init.sh /data/www/pay/php-init.sh
COPY --chown=clonetrooper:clonetrooper ./assets /data/www/pay/backend/web/assets

##初始化php环境，可根据需求修改，1为生产环境，0为测试环境。此步骤还可更新composer，请根据具体需求更改
RUN  echo -e '1\nyes\n'|php init && \
#     composer update -vvv 
#     echo -e 'yes\n'|/bin/sh php-init.sh && \
     git pull origin master  && \
     rm /home/clonetrooper/ssh/id_rsa
